# coding: utf-8
from . import db, BaseModel

from .psy_consultant import PsyConsultant
from .consulter import Consulter




class Consulting(db.Model):
    __tablename__ = 'consulting'

    auto_id = db.Column(db.BigInteger, primary_key=True, info='自增id')
    consult_id = db.Column(db.BigInteger, index=True, info='咨询id')
    con_id = db.Column(db.ForeignKey('consulter.con_id'), index=True, info='咨询者id')
    psy_id = db.Column(db.ForeignKey('psy_consultant.psy_id'), index=True, info='咨询师id')
    start_time = db.Column(db.DateTime, info='预约开始时间')
    end_time = db.Column(db.DateTime, info='预约结束时间')
    is_online = db.Column(db.Integer, info='是否线上进行 1-是 0-否')
    address = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), server_default=db.FetchedValue(), info='线下地址，可为null')
    status = db.Column(db.Integer, server_default=db.FetchedValue(), info='预约状态')
    is_delete = db.Column(db.Integer, server_default=db.FetchedValue(), info='是否已删除 1-是 0-否')
    create_time = db.Column(db.DateTime, server_default=db.FetchedValue(), info='创建时间')
    update_time = db.Column(db.DateTime, server_default=db.FetchedValue(), info='更新时间')

    con = db.relationship('Consulter', primaryjoin='Consulting.con_id == Consulter.con_id', backref='consultings')
    psy = db.relationship('PsyConsultant', primaryjoin='Consulting.psy_id == PsyConsultant.psy_id', backref='consultings')
